#ifndef AUDIOENCODETASK_H
#define AUDIOENCODETASK_H

#include <ClientImpl/Receive_handler.h>
#include <Task_Base/Task_Base.h>
#include <libavinclude.h>
#include <faac.h>
class AudioEncodeTask: public Task_Base ,public Receive_handler
{
public:
    AudioEncodeTask(Receive_handler*);

    ~AudioEncodeTask();
public:
    virtual int close();

    virtual bool receive_handler(char *data,int size);
protected:
    virtual int svc();//主动工作线程函数
private:

    faacEncHandle (*pfaacEncOpen)(unsigned long sampleRate,
                      unsigned int numChannels,
                      unsigned long *inputSamples,
                      unsigned long *maxOutputBytes);

    faacEncConfigurationPtr (*pfaacEncGetCurrentConfiguration)(faacEncHandle hEncoder);

    int FAACAPI (*pfaacEncSetConfiguration)(faacEncHandle hEncoder,
                      faacEncConfigurationPtr config);

  int FAACAPI (*pfaacEncClose)(faacEncHandle hEncoder);

  int FAACAPI (*pfaacEncEncode)(faacEncHandle hEncoder, int32_t * inputBuffer, unsigned int samplesInput,unsigned char *outputBuffer,unsigned int bufferSize);

    faacEncHandle hEncoder;

    faacEncConfigurationPtr pConfiguration;

    int nPCMBufferSize;

    unsigned int nPCMBitSize;

    unsigned long nInputSamples;

    unsigned long nMaxOutputBytes;

    unsigned char * pbPCMBuffer;

    unsigned char * pbAACBuffer;

    Receive_handler *m_pHandler;

     void           *pSo_handler;

     FILE* outfile;

     int m_pack_num1;
     int m_pack_num2;
};

#endif // AUDIOENCODETASK_H
